//
//  WeiAiMainViewController.m
//  uniquelove
//
//  Created by ibokan on 14-12-6.
//  Copyright (c) 2014年 ibokan. All rights reserved.
//

#import "WeiAiMainViewController.h"
#import "LoadingViewController.h"
#import "LoadedWeiBoViewController.h"
@interface WeiAiMainViewController ()
- (IBAction)registerBtnClicked:(id)sender;

@end

@implementation WeiAiMainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


- (IBAction)registerBtnClicked:(id)sender {
    
    
     //找到存储在NSUserDefaults里面的expirationDate（验证过期时间）
     NSDate *date = [[NSUserDefaults standardUserDefaults]objectForKey:@"expirationDate"];
     
     //找到
     UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
     
     //有效期内
     if (date != nil && [date timeIntervalSinceNow] >= 0) {
     //拿到identifier为@“registerweiai”的controller
         LoadedWeiBoViewController *loadedweiaiController = (LoadedWeiBoViewController *)[mainStoryBoard instantiateViewControllerWithIdentifier:@"loadedweibo"];
         [self.navigationController pushViewController:loadedweiaiController animated:YES];
     }else{
     //有效期外
     //拿到identifier为@“login”的controller
     LoadingViewController *loginController = (LoadingViewController *)[mainStoryBoard instantiateViewControllerWithIdentifier:@"login"];
     [self.navigationController pushViewController:loginController animated:YES];
     }
    
}
@end
